    #include <gtk/gtk.h>


static GtkWidget *mytree;
static GtkWidget *window;
    enum {
        COLUMN = 0,
        N_COLUMNS
    };
    static void init_list()
    {

        GtkCellRenderer *renderer;
        GtkTreeViewColumn *column;
        GtkTreeStore *store;

	mytree = gtk_tree_view_new();
        renderer = gtk_cell_renderer_text_new();
        column = gtk_tree_view_column_new_with_attributes("List Items", renderer, "text", COLUMN, NULL);
        gtk_tree_view_append_column(GTK_TREE_VIEW(mytree), column);
        store = gtk_tree_store_new(N_COLUMNS, G_TYPE_STRING);
        gtk_tree_view_set_model(GTK_TREE_VIEW(mytree), GTK_TREE_MODEL(store));
        g_object_unref(store);


    }

    static void add_to_list()
    {
	
        GtkTreeStore *treestore;
        GtkTreeIter toplevel,child,group;
        treestore = GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(mytree)));
//	gtk_list_store_append(store, &iter);
//	gtk_list_store_set(store, &iter, COLUMN, str, -1);

	gtk_tree_store_append(treestore, &group, NULL);
	gtk_tree_store_set(treestore, &group, COLUMN, "Scripting languages", -1);
	gtk_tree_store_append(treestore, &child, &group);
	gtk_tree_store_set(treestore, &child, COLUMN, "Python", -1);
	gtk_tree_store_append(treestore, &child, &group);
	gtk_tree_store_set(treestore, &child, COLUMN, "Perl", -1);
	gtk_tree_store_append(treestore, &child, &group);
	gtk_tree_store_set(treestore, &child, COLUMN, "PHP", -1);

	gtk_tree_store_append(treestore, &toplevel, NULL);
	gtk_tree_store_set(treestore, &toplevel, COLUMN, "Compiled languages", -1);
	gtk_tree_store_append(treestore, &child, &toplevel);
	gtk_tree_store_set(treestore, &child, COLUMN, "C", -1);
	gtk_tree_store_append(treestore, &child, &toplevel);
	gtk_tree_store_set(treestore, &child, COLUMN, "C ", -1);
	gtk_tree_store_append(treestore, &child, &toplevel);
	gtk_tree_store_set(treestore, &child, COLUMN, "Java", -1);
	g_object_unref(treestore);
    }

    void on_changed(GtkWidget * widget, gpointer label)
    {
        GtkTreeIter iter;
        GtkTreeModel *model;
        char *value;
        if (gtk_tree_selection_get_selected(GTK_TREE_SELECTION(widget), &model, &iter)) {
            gtk_tree_model_get(model, &iter, COLUMN, &value, -1);
            gtk_label_set_text(GTK_LABEL(label), value);
            g_free(value);
        }
    }
GtkWidget * createWindow()
{
	GtkWidget *window;
        GtkWidget *vbox;
        GtkWidget *label;
	GtkWidget *scroll;
        GtkTreeSelection *selection;

        
        window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
        gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
        gtk_container_set_border_width(GTK_CONTAINER(window), 10);
        gtk_widget_set_size_request(window, 270, 250);
        gtk_window_set_title(GTK_WINDOW(window), "List View");
	
	scroll = gtk_scrolled_window_new(NULL,NULL);
	gtk_container_add(GTK_CONTAINER(window), scroll);

        init_list();
        gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(mytree), TRUE);
        vbox = gtk_vbox_new(FALSE, 0);
        gtk_box_pack_start(GTK_BOX(vbox), mytree, TRUE, TRUE, 5);
        label = gtk_label_new("");
        gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_CENTER);
        gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 5);
        gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scroll),vbox);

	//init_list();
        add_to_list();
	return window;
       
}
    int main(int argc, char *argv[])
    {
        gtk_init(&argc, &argv);
	window = createWindow();
        //selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(list));
        //g_signal_connect(selection, "changed", G_CALLBACK(on_changed), label);
	 

        g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(gtk_main_quit), NULL);
        gtk_widget_show_all(window);
        gtk_main();
        return 0;
    }
